import { takeEvery, put } from 'redux-saga/effects'
import axios from 'axios'
import {loadDataSync} from './actionCreator'

function* loadDataApply() {
    const result = yield axios.get(
        '/api/user'
    )
    yield put(loadDataSync(result.data[0]))
}

function* addDoctorTeam(action) {
    const result = yield axios.patch(
        '/api/user/'+action.userid,
        {"doctorTeamid":action.doctorTeamid}
    )

}

function* ApplySaga() {
    yield takeEvery('loadDataApplySaga', loadDataApply)
    yield takeEvery('addDoctorTeamSaga', addDoctorTeam)
}

export default ApplySaga